package com.wain.util;

import cn.hutool.core.util.StrUtil;
import com.wain.entity.FunctionInfo;
import com.wain.entity.JspInfo;
import org.apache.commons.codec.binary.StringUtils;
import org.apache.poi.ss.usermodel.*;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class JspCodeAndName {

    public static void main(String[] args) {
        List<FunctionInfo> functionInfos = functionInfos();
    }

    private static List<FunctionInfo> functionInfos() {
        List<FunctionInfo> infos = new ArrayList<FunctionInfo>();
        String excelFile = "F:\\javaItem\\functionInfo\\システム機能一覧_（2023年7月版）.xlsx"; // 替换为您的Excel文件名
        try {
            Workbook workbook = WorkbookFactory.create(new FileInputStream(excelFile));
            Sheet sheet = workbook.getSheetAt(0); // 读取第一个工作表
            // 遍历单元格
            for (int i = 4; i < sheet.getLastRowNum(); i++) {

                Row row = sheet.getRow(i);
                String cell5 = row.getCell(8).getStringCellValue();
                if (!StrUtil.hasEmpty(cell5) && cell5.equals("画面")){
                    FunctionInfo info = new FunctionInfo();
                    info.setId(row.getCell(5).getStringCellValue());
                    info.setName(row.getCell(6).getStringCellValue());
                    info.setSummary(row.getCell(7).getStringCellValue());
                    infos.add(info);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        for (FunctionInfo one : infos){
            System.out.println(one.toString());
        }

        return infos;
    }

    private HashMap JspFile(String FileName) {
        HashMap<String, List<JspInfo>> info = new HashMap<String, List<JspInfo>>();
        return info;
    }
}
